package no.spk.util.inforama.service.impl;

import java.util.ArrayList;
import java.util.List;

import no.spk.util.inforama.service.InfoRamaService;
import no.spk.util.inforama.service.applicationserver.ApplicationServerAnalyzer;
import no.spk.util.inforama.service.container.Container;
import no.spk.util.inforama.service.deployable.Deployable;
/**
 * @author Marius Breivik - Accenture
 */
public class InfoRamaServiceImpl implements InfoRamaService {

	private List<Container> containers;

	private ApplicationServerAnalyzer applicationServerAnalyzer;

	public InfoRamaServiceImpl(ApplicationServerAnalyzer applicationServerAnalyzer) {
		this.applicationServerAnalyzer = applicationServerAnalyzer;
		containers = applicationServerAnalyzer.createContainers();
		System.out.println("JIPPI!");
	}

	public List<Deployable> getDeployables(String containerName) {
		for(Container container: containers){
			if (container.getName().equalsIgnoreCase(containerName)){
				return container.getDeployables();
			}
		}
		throw new RuntimeException("No container with name " + containerName);
	}

	public List<String> getContainerNames() {
		List<String> containerNames = new ArrayList<String>();
		for(Container container : containers){
			containerNames.add(container.getName());
		}
		return containerNames;
	}

}
